package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.ConcentratorInfo;
import com.ruoyi.ftrl.service.IConcentratorInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 集中器信息Controller
 * 
 * @author dihang
 * @date 2024-08-21
 */
@RestController
@RequestMapping("/ftrl/concentrator")
public class ConcentratorInfoController extends BaseController
{
    @Autowired
    private IConcentratorInfoService concentratorInfoService;

    /**
     * 查询集中器信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:list')")
    @GetMapping("/list")
    public TableDataInfo list(ConcentratorInfo concentratorInfo)
    {
        startPage();
        List<ConcentratorInfo> list = concentratorInfoService.selectConcentratorInfoList(concentratorInfo);
        return getDataTable(list);
    }

    /**
     * 导出集中器信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:export')")
    @Log(title = "集中器信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ConcentratorInfo concentratorInfo)
    {
        List<ConcentratorInfo> list = concentratorInfoService.selectConcentratorInfoList(concentratorInfo);
        ExcelUtil<ConcentratorInfo> util = new ExcelUtil<ConcentratorInfo>(ConcentratorInfo.class);
        util.exportExcel(response, list, "集中器信息数据");
    }

    /**
     * 获取集中器信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(concentratorInfoService.selectConcentratorInfoById(id));
    }

    /**
     * 新增集中器信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:add')")
    @Log(title = "集中器信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ConcentratorInfo concentratorInfo)
    {
        return toAjax(concentratorInfoService.insertConcentratorInfo(concentratorInfo));
    }

    /**
     * 修改集中器信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:edit')")
    @Log(title = "集中器信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ConcentratorInfo concentratorInfo)
    {
        return toAjax(concentratorInfoService.updateConcentratorInfo(concentratorInfo));
    }

    /**
     * 删除集中器信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:concentrator:remove')")
    @Log(title = "集中器信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(concentratorInfoService.deleteConcentratorInfoByIds(ids));
    }
}
